<template>
  <div class="page">
	<div class="layui-fluid">
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md12">
					<div class="layui-card">

						<div class="layui-card-body">
							<div class="layui-form" lay-filter="">

								<div class="layui-form-item">
									<div class="layui-inline">
									    <label class="layui-form-label">银行账户</label>
									    <div class="layui-input-inline" >
									        <input type="text" name="name"  placeholder="银行账户"  autocomplete="off" class="layui-input a"  v-model="account">
									    </div>
								  </div>
								</div>
								
								<div class="layui-form-item">
									<div class="layui-inline">
									    <label class="layui-form-label">银行种类</label>
									     <div class="layui-input-block">
										    <div class="layui-input-inline" style="width: 180px;margin-bottom:10px">
										       <select lay-filter="banktype">		
														<option :value="item.id" v-for="item in banktype">{{item.name}}</option>
													</select>
										    </div>
										  </div>
								  </div>
								</div>
						    
						   <div class="layui-form-item">
									<div class="layui-inline">
									    <label class="layui-form-label">支行名称 </label>
									    <div class="layui-input-inline" >
									        <input type="text" name="name" placeholder="标题" v-model="branch"   autocomplete="off" class="layui-input a" >
									    </div>
								  </div>
								</div>
								
								<div class="layui-form-item">
									<div class="layui-inline">
									    <label class="layui-form-label">真实姓名</label>
									    <div class="layui-input-inline" >
									        <input type="text" name="name" placeholder="标题"  v-model="name"   autocomplete="off" class="layui-input a" >
									    </div>
								  </div>
								</div>

								<div class="layui-form-item">
									<div class="layui-input-block">
										<button class="layui-btn layui-btn-normal" lay-submit lay-filter="setmyinfo" @click="sure">确认</button>
									</div>
								</div>
								
								
								
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
  </div>
</template>
<script>

export default {
  name: 'goodsfladd',
  data () {
    return {
		  "account": "",
	    "branch": "",
	    "name": "",
	    "bankType": {
	      "id": ""
	    },
		  "id": "",
		  banktype:[]
		}
  },
  mounted(){
    var _this = this;
    window.getdates = this.getdates;
		this.getbanktype()
  },
  methods: {
  	getdates:function(dates){
  		this.id=dates.id
  	},
  	getbanktype:function(){
  		var _this=this;
  		var url='/pay/papi/v1.9/bank-type'
  		ajaxRequest(url,'GET','json','',function(ret,err){
				_this.banktype=ret.data
				_this.bankType.id=ret.data[0].id
			})
  	},
  	
		sure:function(){
			var _this = this;
			var len = $(".a").length;
			for(var i = 0; i < len; i++) {
				if($(".a").eq(i).val() == ''||$(".a").eq(i).val()<=0) {
					var msg = $(".a").eq(i).attr("placeholder");
					layer.msg('请输入正确的'+msg);
					return;
				}
			}
			var url='/pay/bapi/v1.9/settlement/updateApplyBank'
			var dates={
				"bank": {
				    "account": this.account,
				    "bankPaytype": "BANKPAYTYPE_BANK",
				    "branch": this.branch,
				    "isFirst": "FIRSTSET_NO",
				    "realname": this.name,
				    "bankType":this.bankType
				 },
				 "id":this.id,
				 
				
			}
			ajaxRequest(url, 'PUT', 'json',dates, function(ret, err){
			  layer.msg("操作成功");
			  setTimeout(function(){
			  	var index = parent.layer.getFrameIndex(window.name);
			    parent.layer.close(index);
		      parent.location.reload();
	      },1000)
			})
		}
  },
  updated:function(){
  	var _this=this;

		layui.use('form', function(){
		  var form = layui.form;
		  form.render();
		  form.on('select(banktype)', function(data){
				 	_this.bankType.id=data.value
			});

		});

  },
}
</script>
<style scoped>
</style>
